home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / Libraries / SAT 2.3b4 / Misc / FaceFromPICT.p < prev    next >
Text File  |  1995-05-01  |  1KB  |  61 lines

  1. unit FaceFromPICT;
  2.  
  3. interface
  4.     uses
  5. {$IFC UNDEFINED THINK_PASCAL}
  6.         Types, QuickDraw, Memory, Resources, ToolUtils, 
  7. {$ENDC}
  8.         SAT;
  9.  
  10.     function GetFaceFromPICT (colorPICTid, bwPICTid, maskPICTid: integer): FacePtr;
  11.  
  12. implementation
  13.  
  14. {No error checking yet!}
  15.  
  16.     function GetFaceFromPICT (colorPICTid, bwPICTid, maskPICTid: integer): FacePtr;
  17.         var
  18.             bounds: Rect;
  19.             thePICT, maskPICT: PicHandle;
  20.             theFace: FacePtr;
  21.             savePort: SATPort;
  22.     begin
  23.         SATGetPort(savePort);
  24.  
  25. {Get PICTs}
  26. {IDEA: It should really check if the PICT it loads was loaded already, and if it was, don't dispose it.}
  27.         if gSAT.initDepth > 1 then
  28.             thePICT := GetPicture(colorPICTid)
  29.         else
  30.             thePICT := GetPicture(bwPICTid);
  31.         maskPICT := GetPicture(maskPICTid);
  32.         bounds := thePICT^^.picFrame;
  33.         OffsetRect(bounds, -bounds.left, -bounds.top); {onödigt för det gör NewFace åt oss.}
  34.  
  35.         if (thePICT = nil) or (maskPICT = nil) then
  36.             begin
  37.                 GetFaceFromPICT := nil;
  38.                 exit(GetFaceFromPICT);
  39.             end;
  40.  
  41. {Create face}
  42.         theFace := SATNewFace(bounds);
  43.  
  44. {Draw in the face}
  45.         SATSetPortFace(theFace);
  46.         DrawPicture(thePICT, bounds);
  47.         SATSetPortMask(theFace);
  48.         DrawPicture(maskPICT, bounds);
  49. {Tell SAT that we are done}
  50.         SATChangedFace(theFace);
  51.  
  52. {Get rid of the PICTs}
  53.         ReleaseResource(Handle(thePICT));
  54.         ReleaseResource(Handle(maskPICT));
  55.  
  56. {Return the face.}
  57.         GetFaceFromPICT := theFace;
  58.  
  59.         SATSetPort(savePort);
  60.     end;
  61. end.